<template>
  <view class="leftnavbar">
    <uv-popup ref="popup" mode="left" custom-style="width: 334rpx;">
      <view class="dialog">
        <image class="logo_left" src="../../static/images/logo_left.png" mode=""></image>
        <view class="menu">
          <view class="menu-item" @click="setMenuIndex(index)" :class="currentMenuIndex == index?'menuActive':''"
            v-for="(item, index) in menuList" :key="index">
            {{item.name}}
          </view>
        </view>
      </view>
    </uv-popup>
  </view>
</template>

<script>
  export default {
    name:"leftnavbar",
    props: {
      currentIndex: {
        type: Number,
        default: 0
      }
    },
    data() {
      return {
        menuList: [{
            name: this.$i18n.t('aboutus'),
            path: "/pages/home/about"
          },
          {
            name: this.$i18n.t('software and hardware'),
            path: "/pages/home/software"
          },
          {
            name: this.$i18n.t('Performance'),
            path: "/pages/home/achievement"
          },
          {
            name: "QHSEE",
            path: "/pages/home/qhsee"
          },
          {
            name: "ESG",
            path: "/pages/home/esg"
          },
          {
            name: this.$i18n.t('purchase'),
            path: "/pages/home/purchase"
          }
        ],
        currentMenuIndex: 0
      };
    },
    created() {
      console.log("currentIndex", this.currentIndex);
      this.currentMenuIndex = this.currentIndex;
    },
    methods:{
      open(){
        this.$refs.popup.open();
      },
      setMenuIndex(index) {
        this.currentMenuIndex = index;
        this.$emit("jump", this.menuList[index].path);
        this.$refs.popup.close();
      },
    }
  }
</script>

<style lang="scss" scoped>
.leftnavbar{
  .dialog {
    padding: 30rpx;
    box-sizing: border-box;
  
    .menuActive {
      background: rgba(16, 70, 130, 0.16) !important;
      color: #104682 !important;
    }
  
    .logo_left {
      width: 100%;
      height: 54rpx;
      margin-bottom: 56rpx;
    }
  
    .menu {
      .menu-item {
        width: 270rpx;
        height: 72rpx;
        text-align: center;
        line-height: 72rpx;
        margin-bottom: 20rpx;
      }
    }
  }
}
</style>